package com.geeaks.learn.test;

import java.io.File;
import java.util.List;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import cn.hutool.core.util.StrUtil;

public class GenCarZDSQL {
	
	static String path = "/Users/geeaks/Desktop/11000010001202000000003_20181101 165053_20190106_General.csv";
	
	static String sqlTemplate = "({}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, now()),";
	
	public static void main(String[] args) throws Exception {
		List<String> lines = FileUtils.readLines(new File(path));
		String prefix = "INSERT INTO xwcarzd_summary(date, last_inloan, today_inloan, loan_num, loan_amount, repay_num, repay_amount, repay_bj, repay_lx, repay_fy, repay_fx, xw_repay_bj, xw_repay_lx, xw_repay_fx, pt_repay_lx, pt_repay_fx, pt_repay_fy, create_time) VALUES ";
		for(String line : lines) {
			String[] split = line.split(",");
			String sql = StrUtil.format(sqlTemplate, split[0].trim(),split[1].trim(),split[2].trim(),split[3].trim(),split[4].trim(),split[5].trim(),split[6].trim(),split[7].trim(),split[8].trim(),split[9].trim(),split[10].trim(),split[11].trim(),split[12].trim(),split[13].trim(),split[14].trim(),split[15].trim(),split[16].trim());
			prefix += sql;
		}
		System.out.println(StringUtils.removeEnd(prefix, ","));
	}
}
